import React from "react";
import { HashRouter, Switch, Route, Link,withRouter } from "react-router-dom";
import { routes } from "./router/index";
import TabBar from "./components/tabbar";
class App extends React.PureComponent {
  constructor (props) {
    super()
  }
  render () {
    return <div>
    <HashRouter>
      <div>
        <Link to={{ pathname: "/button" }}>按钮1</Link> <br />
        <Link to={{ pathname: "/" }}>首页</Link>
      </div>
      <Switch>
        <Route
          exact={true}
          render={() => {
            return <div>默认路由首页</div>;
          }}
          path="/"
        ></Route>

        {routes.map((res) => {
          return (
            <Route
              key={res.path}
              component={res.component}
              path={res.path}
              exact={res.exact}
            ></Route>
          );
        })}

        <Route
          render={() => {
            return <div>404</div>;
          }}
          path="*"
        ></Route>
      </Switch>
    </HashRouter>
    <div className="tab-bar">
      <TabBar></TabBar>
    </div>
  </div>
  }
}

export default withRouter(App)